using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class ItemRequestDetailInfo
    {
		#region Local Variable
		public enum Field
		{
			DTB,
			RequestRef,
			DetailNo,
			ItemCate,
			SubCode1,
			SubCode2,
			ItemDescription,
			PartNo,
			Unit,
			Department,
			MinLevel,
			MaxLevel,
			Remark
		}
		private String _DTB;
		private String _RequestRef;
		private Int32 _DetailNo;
		private String _ItemCate;
		private String _SubCode1;
		private String _SubCode2;
		private String _ItemDescription;
		private String _PartNo;
		private String _Unit;
		private String _Department;
		private Int32 _MinLevel;
		private Int32 _MaxLevel;
		private String _Remark;
		
		public String DTB{	get{ return _DTB;} set{_DTB = value;} }
		public String RequestRef{	get{ return _RequestRef;} set{_RequestRef = value;} }
		public Int32 DetailNo{	get{ return _DetailNo;} set{_DetailNo = value;} }
		public String ItemCate{	get{ return _ItemCate;} set{_ItemCate = value;} }
		public String SubCode1{	get{ return _SubCode1;} set{_SubCode1 = value;} }
		public String SubCode2{	get{ return _SubCode2;} set{_SubCode2 = value;} }
		public String ItemDescription{	get{ return _ItemDescription;} set{_ItemDescription = value;} }
		public String PartNo{	get{ return _PartNo;} set{_PartNo = value;} }
		public String Unit{	get{ return _Unit;} set{_Unit = value;} }
		public String Department{	get{ return _Department;} set{_Department = value;} }
		public Int32 MinLevel{	get{ return _MinLevel;} set{_MinLevel = value;} }
		public Int32 MaxLevel{	get{ return _MaxLevel;} set{_MaxLevel = value;} }
		public String Remark{	get{ return _Remark;} set{_Remark = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public ItemRequestDetailInfo()
		{
			_DTB = "";
			_RequestRef = "";
			_DetailNo = 0;
			_ItemCate = "";
			_SubCode1 = "";
			_SubCode2 = "";
			_ItemDescription = "";
			_PartNo = "";
			_Unit = "";
			_Department = "";
			_MinLevel = 0;
			_MaxLevel = 0;
			_Remark = "";
		}
		
		public ItemRequestDetailInfo(
		String DTB,
		String RequestRef,
		Int32 DetailNo,
		String ItemCate,
		String SubCode1,
		String SubCode2,
		String ItemDescription,
		String PartNo,
		String Unit,
		String Department,
		Int32 MinLevel,
		Int32 MaxLevel,
		String Remark
		)
		{
			_DTB = DTB;
			_RequestRef = RequestRef;
			_DetailNo = DetailNo;
			_ItemCate = ItemCate;
			_SubCode1 = SubCode1;
			_SubCode2 = SubCode2;
			_ItemDescription = ItemDescription;
			_PartNo = PartNo;
			_Unit = Unit;
			_Department = Department;
			_MinLevel = MinLevel;
			_MaxLevel = MaxLevel;
			_Remark = Remark;
		}
		public ItemRequestDetailInfo(DataRow dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestRef = dr[Field.RequestRef.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestRef.ToString()]);
				_DetailNo = dr[Field.DetailNo.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.DetailNo.ToString()]);
				_ItemCate = dr[Field.ItemCate.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemCate.ToString()]);
				_SubCode1 = dr[Field.SubCode1.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SubCode1.ToString()]);
				_SubCode2 = dr[Field.SubCode2.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SubCode2.ToString()]);
				_ItemDescription = dr[Field.ItemDescription.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemDescription.ToString()]);
				_PartNo = dr[Field.PartNo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.PartNo.ToString()]);
				_Unit = dr[Field.Unit.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Unit.ToString()]);
				_Department = dr[Field.Department.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Department.ToString()]);
				_MinLevel = dr[Field.MinLevel.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.MinLevel.ToString()]);
				_MaxLevel = dr[Field.MaxLevel.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.MaxLevel.ToString()]);
				_Remark = dr[Field.Remark.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Remark.ToString()]);
			}
		}
		public ItemRequestDetailInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestRef = dr[Field.RequestRef.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestRef.ToString()]);
				_DetailNo = dr[Field.DetailNo.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.DetailNo.ToString()]);
				_ItemCate = dr[Field.ItemCate.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemCate.ToString()]);
				_SubCode1 = dr[Field.SubCode1.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SubCode1.ToString()]);
				_SubCode2 = dr[Field.SubCode2.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SubCode2.ToString()]);
				_ItemDescription = dr[Field.ItemDescription.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ItemDescription.ToString()]);
				_PartNo = dr[Field.PartNo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.PartNo.ToString()]);
				_Unit = dr[Field.Unit.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Unit.ToString()]);
				_Department = dr[Field.Department.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Department.ToString()]);
				_MinLevel = dr[Field.MinLevel.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.MinLevel.ToString()]);
				_MaxLevel = dr[Field.MaxLevel.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.MaxLevel.ToString()]);
				_Remark = dr[Field.Remark.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Remark.ToString()]);
			}
		}
		public ItemRequestDetailInfo(ItemRequestDetailInfo objEntr)
		{			
			_DTB = objEntr.DTB;			
			_RequestRef = objEntr.RequestRef;			
			_DetailNo = objEntr.DetailNo;			
			_ItemCate = objEntr.ItemCate;			
			_SubCode1 = objEntr.SubCode1;			
			_SubCode2 = objEntr.SubCode2;			
			_ItemDescription = objEntr.ItemDescription;			
			_PartNo = objEntr.PartNo;			
			_Unit = objEntr.Unit;			
			_Department = objEntr.Department;			
			_MinLevel = objEntr.MinLevel;			
			_MaxLevel = objEntr.MaxLevel;			
			_Remark = objEntr.Remark;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("ItemRequestDetail");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.DTB.ToString(), typeof(String)),
				new DataColumn(Field.RequestRef.ToString(), typeof(String)),
				new DataColumn(Field.DetailNo.ToString(), typeof(Int32)),
				new DataColumn(Field.ItemCate.ToString(), typeof(String)),
				new DataColumn(Field.SubCode1.ToString(), typeof(String)),
				new DataColumn(Field.SubCode2.ToString(), typeof(String)),
				new DataColumn(Field.ItemDescription.ToString(), typeof(String)),
				new DataColumn(Field.PartNo.ToString(), typeof(String)),
				new DataColumn(Field.Unit.ToString(), typeof(String)),
				new DataColumn(Field.Department.ToString(), typeof(String)),
				new DataColumn(Field.MinLevel.ToString(), typeof(Int32)),
				new DataColumn(Field.MaxLevel.ToString(), typeof(Int32)),
				new DataColumn(Field.Remark.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.DTB.ToString()] = _DTB;
			row[Field.RequestRef.ToString()] = _RequestRef;
			row[Field.DetailNo.ToString()] = _DetailNo;
			row[Field.ItemCate.ToString()] = _ItemCate;
			row[Field.SubCode1.ToString()] = _SubCode1;
			row[Field.SubCode2.ToString()] = _SubCode2;
			row[Field.ItemDescription.ToString()] = _ItemDescription;
			row[Field.PartNo.ToString()] = _PartNo;
			row[Field.Unit.ToString()] = _Unit;
			row[Field.Department.ToString()] = _Department;
			row[Field.MinLevel.ToString()] = _MinLevel;
			row[Field.MaxLevel.ToString()] = _MaxLevel;
			row[Field.Remark.ToString()] = _Remark;
			return row;
		}
        #endregion InitTable
    }
}
